package com.yunji.base.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.base.dao.IAgentSiteDao;
import com.yunji.base.domain.AgentSiteDO;
import com.yunji.base.mapper.IAgentSiteMapper;
import com.yunji.common.base.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.Arrays;
import java.util.List;

/**
 * @author : peter-zhu
 * @date : 2024/12/10 13:42
 * @description : TODO
 **/
@Repository
public class AgentSiteDaoImpl extends BaseDaoImpl<IAgentSiteMapper, AgentSiteDO> implements IAgentSiteDao {
    @Override
    public List<AgentSiteDO> search(AgentSiteDO agentSite) {
        return lambdaQuery()
                .eq(agentSite.getAgentId() != null, AgentSiteDO::getAgentId, agentSite.getAgentId())
                .eq(agentSite.getSiteId() != null, AgentSiteDO::getSiteId, agentSite.getSiteId())
                .list();
    }

    @Override
    public List<AgentSiteDO> listBySiteIds(List<Long> list) {
        return lambdaQuery().eq(AgentSiteDO::getSiteId, list).list();
    }

    @Override
    public boolean deleteBySiteIds(Long... ids) {
        return remove(new LambdaQueryWrapper<AgentSiteDO>()
                .in(AgentSiteDO::getSiteId, Arrays.asList(ids)));
    }
}
